package pers.litao.bit.user.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.jsonwebtoken.Claims;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import pers.litao.bit.commons.entities.user.AddressEntity;
import pers.litao.bit.commons.utils.Constant;
import pers.litao.bit.commons.utils.JwtUtil;
import pers.litao.bit.commons.utils.R;
import pers.litao.bit.commons.utils.SysUtil;
import pers.litao.bit.user.dao.AddressMapper;
import pers.litao.bit.user.service.AddressService;

import java.util.List;

/**
 * @author 李涛
 * @date 2020-11-24 15:41
 */
@Service
@Slf4j
public class AddressServiceImpl extends ServiceImpl<AddressMapper, AddressEntity> implements AddressService {
    /**
     * 获取用户地址，内部调用
     *
     * @param userId
     * @return
     */
    @Override
    public R getUserAddress(Long userId) {
        List<AddressEntity> userAddress = this.baseMapper.selectList(new QueryWrapper<AddressEntity>()
                .eq("user_id", userId));
        log.info("用户请求成功" + SysUtil.getClientInfo().buildInfo());
        return R.ok(userAddress.get(0));
    }
}
